//
//  UICollectionView+JJExtension.swift
//  JJToolSwift
//
//  Created by heihei on 2024/5/14.
//

import Foundation

public extension UICollectionView {
    /// 注册UICollectionViewCell
    /// - Parameter cellName: 要注册的cell
    func registerCell(cellName: UICollectionViewCell.Type) {
        self.register(UINib(nibName: String(describing: cellName),
                            bundle: Bundle.main),
                      forCellWithReuseIdentifier: String(describing: cellName))
    }
    
    /// 注册UICollectionView的sectionHeader和footer
    /// - Parameters:
    ///   - viewName: 要注册的view
    ///   - isHeader: 是否是header
    func registerReusableView(viewName: UICollectionReusableView.Type, isHeader: Bool) {
        self.register(UINib(nibName: String(describing: viewName), bundle: Bundle.main), forSupplementaryViewOfKind: isHeader ? UICollectionView.elementKindSectionHeader : UICollectionView.elementKindSectionFooter, withReuseIdentifier: String(describing: viewName))
    }
}
